/* =============================================================================
 * BeeWorks MoneyPile - Domain Model
 *
 * 
 * =============================================================================
 *
 * Developers: Jurgen Lust
 *
 * 
 * (C) Copyright 2009, BeeWorks BVBA.
 *
 */

package be.beeworks.moneypile.model;

import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;

import java.io.Serializable;

import java.util.UUID;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlIDREF;
import javax.xml.bind.annotation.XmlRootElement;


/**
 * A Project
 *
 * @author jlust
 * @author $LastChangedBy: Jurgen.Lust $
 *
 * @version $LastChangedRevision: 15 $
 */
@Entity
@Table(name = "PROJECTS")
@Indexed
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Project
        implements Serializable {
    //~ Static fields/initializers ---------------------------------------------

    private static final long serialVersionUID = 7176043472609363116L;

    //~ Instance fields --------------------------------------------------------

    @NotNull
    private Boolean active;
    @NotNull
    @XmlIDREF
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "contact_id_ref", nullable = false)
    private Contact contact;
    @NotNull
    @Min(0)
    private Float holidayHourRate;
    @NotNull
    @Min(0)
    private Float hourRate;
    @NotNull
    @Min(value = 0)
    private Float overtimeHourRate;
    @NotNull
    @Min(0)
    @Max(24)
    private Integer officeHourEnd;
    @NotNull
    @Min(0)
    @Max(24)
    private Integer officeHourStart;
    @Version
    private Long version;
    @NotNull
    @Size(min = 1, max = 16)
    @Field(index = Index.TOKENIZED, store = Store.NO)
    private String code;
    @Id
    @XmlID
    @DocumentId
    @Min(32)
    @Max(32)
    private String id;
    @NotNull
    @Size(min = 1, max = 100)
    @Field(index = Index.TOKENIZED, store = Store.NO)
    private String name;

    //~ Constructors -----------------------------------------------------------

    public Project() {
        super();
        this.id = UUID.randomUUID().toString().replaceAll("-", "");
        this.active = true;
    }

    //~ Methods ----------------------------------------------------------------

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Contact getContact() {
        return contact;
    }

    public void setContact(Contact contact) {
        this.contact = contact;
    }

    public Float getHourRate() {
        return hourRate;
    }

    public void setHourRate(Float hourRate) {
        this.hourRate = hourRate;
    }

    public Float getOvertimeHourRate() {
        return overtimeHourRate;
    }

    public void setOvertimeHourRate(Float overtimeHourRate) {
        this.overtimeHourRate = overtimeHourRate;
    }

    public Float getHolidayHourRate() {
        return holidayHourRate;
    }

    public void setHolidayHourRate(Float holidayHourRate) {
        this.holidayHourRate = holidayHourRate;
    }

    public Integer getOfficeHourStart() {
        return officeHourStart;
    }

    public void setOfficeHourStart(Integer officeHourStart) {
        this.officeHourStart = officeHourStart;
    }

    public Integer getOfficeHourEnd() {
        return officeHourEnd;
    }

    public void setOfficeHourEnd(Integer officeHourEnd) {
        this.officeHourEnd = officeHourEnd;
    }

    public Long getVersion() {
        return version;
    }
}
